<template>
	<view class="rate">

		<view v-if="wzinfo.uid==userInfo.id && wzinfo.evaluate_all<=0">
			<view class="title"><i class="iconfont icon-biaoxing"></i>{{TP}}</view>
			<view class="ratelist">
				<view class="lable">
					<view class="t">答复速度</view><u-rate count="5" minCount="0" v-model="evaluate_speed" gutter="9"
						size="30" activeColor="#2b73df" :readonly="readonly"></u-rate>
				</view>
				<view class="lable">
					<view class="t">解决程度</view><u-rate count="5" minCount="0" v-model="evaluate_quality" gutter="9"
						size="30" activeColor="#2b73df" :readonly="readonly"></u-rate>
				</view>
				<view class="lable">
					<view class="t">办理态度</view><u-rate count="5" minCount="0" v-model="evaluate_satisfied" gutter="9"
						size="30" activeColor="#2b73df" :readonly="readonly"></u-rate>
				</view>
			</view>
			<view class="">
				<view v-if="!readonly">
					<u--textarea v-model="btext" placeholder="请输入评分理由,最多80字" height="70" border="false" :count="true"
						:maxlength="80" customStyle="background:#f8f8f8" cursorSpacing="220"
						:showConfirmBar="false"></u--textarea>
					<view class="writeReply" @click="doActionRate">提交评分</view>
				</view>
				<view v-else>
					{{btext}}
				</view>
			</view>
		</view>
		
		<view v-else>
			<view class="title"><i class="iconfont icon-biaoxing"></i>评价</view>
			<view class="ratelist">
				<view class="lable">
					<view class="t">答复速度</view><u-rate count="5" minCount="0" v-model="wzinfo.evaluate_speed" gutter="9"
						size="30" activeColor="#2b73df" readonly="true"></u-rate>
				</view>
				<view class="lable">
					<view class="t">解决程度</view><u-rate count="5" minCount="0" v-model="wzinfo.evaluate_quality" gutter="9"
						size="30" activeColor="#2b73df"  readonly="true"></u-rate>
				</view>
				<view class="lable">
					<view class="t">办理态度</view><u-rate count="5" minCount="0" v-model="wzinfo.evaluate_satisfied" gutter="9"
						size="30" activeColor="#2b73df"  readonly="true"></u-rate>
				</view>
			</view>
			<view class="">
				<view class="bmsk">总评分：<u-rate count="5" v-model="wzinfo.evaluate_all" gutter="9"
						size="22" activeColor="red" readonly="true"></u-rate><view style="margin-left:10rpx;color:red">{{wzinfo.evaluate_all}} 分</view></view>
				<view>
					{{wzinfo.bmy_reason}}
				</view>
			</view>
		</view>
	</view>
</template>
<style scoped lang="scss">
	.bmsk{
		background-color: #f8f8f8;
		padding:20rpx;
		border-radius: 10rpx;
		margin-bottom:20rpx;
		display: flex;
		fonts-size:24rpx;
	}
	.rate {
		.writeReply {
			background-color: $base-color;
			color: #fff;
			width: 150rpx;
			font-size: 28rpx;
			text-align: center;
			margin-top: 20rpx;
			margin-left: calc(100% - 150rpx);
			height: 50rpx;
			line-height: 50rpx;
			border-radius: 10rpx;
		}

		.title {
			font-size: 17px;
			color: #2b73df;
			position: relative;
			display: flex;
			align-items: center;

			.iconfont {
				font-size: 18px;
				font-weight: bold;
				margin-right: 10px;
			}
		}

		.ratelist {
			margin-top: 20rpx;

			.lable {
				margin: 20rpx 0;
				display: flex;
				align-items: center;
				font-size: 32rpx;

				.t {
					color: #666;
					margin-right: 30rpx;
				}
			}
		}
	}
</style>
<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import {
		doRate
	} from '@/api/api.js';
	export default {
		name: 'Like',
		props: ['wzinfo'],
		data() {
			return {
				TP: '请评分',
				readonly: false,
				evaluate_speed: 0,
				evaluate_quality: 0,
				evaluate_satisfied: 0,
				btext: ''

			}
		},
		mounted(options) {
			// this.Star = this.wzinfo.evaluate_all
		},
		computed: {
			...mapState(['hasLogin', 'userInfo']),
		},
		methods: {
			doActionRate() {
				let _this = this

				doRate({
					wid: _this.wzinfo.wid,
					sat: _this.evaluate_speed,
					spe: _this.evaluate_satisfied,
					qua: _this.evaluate_quality,
					btext: _this.btext
				}).then(r => {
					if (r.data.code == 200) {
						_this.readonly = true
						_this.TP = "评价";
						return false
					} else {
						uni.$u.toast(r.data.msg);
						return fase
					}
				})
			}
		}
	}
</script>